package com.naiterui.ehp.bs.pharmacist.controller;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.pharmacist.service.ISMSService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 发送短信的接口
 *
 * @author chenlin
 */
@Api(tags = SwaggerTag.PHARMACIST + SwaggerTag.USER_ACCOUNT)
@RestController
@RequestMapping("pharmacist")
public class PharmacistSendSMSController {

    private static final Logger LOGGER = LoggerFactory.getLogger(PharmacistSendSMSController.class);

    @Autowired
    private ISMSService smsService;

    /**
     * @param phoneNum   输入手机号码
     * @param actionType 功能类型(1/注册；2/忘记密码；3/修改手机号；4/修改密码; 5/登录验证; 6/登录验证-2.5.0优化后; 7/修改签名密码;)
     *
     * @return
     */
    @ApiOperation(value = "发送短信", notes = "发送验证短信", httpMethod = "POST")
    @ApiImplicitParams({@ApiImplicitParam(name = "phoneNum", value = "手机号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "actionType", value = "请求类型((1/注册；2/忘记密码；3/修改手机号；4/修改密码; 5/登录验证; 6/登录验证-2.5.0优化后; 7/修改签名密码;)",
                    allowableValues = "1,2,3,4,5,6,7", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "t", value = "签名时间戳", required = true, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "sign", value = "签名", required = true, dataType = "string", paramType = "query"),})
    @RequestMapping(value = "/sendSms")
    @ResponseBody
    public void sendSMs(String phoneNum, Integer actionType, Long t, String sign) throws BusinessException {
        LOGGER.info("发送短信 请求参数：phoneNum = [{}], actionType = [{}], t = [{}], sign = [{}]", phoneNum, actionType, t, sign);

        this.smsService.sendSMs(phoneNum, actionType, t, sign);
    }


}
